Skip to content

Conversation

@sternb0t
Copy link

It would be handy to allow themes to override the rendering logic for a zone's widget. For example, a theme may want to include special CSS classes, or additional content such as thumbnail images or custom taxonomy. This is one way to implement this. Happy to try a different approach, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool idea. A better pattern I've found is to have false value passed to a filter and if unchanged, do the default render; something like:

$html = apply_filters( 'widget_zone_posts_override_html', false, $posts );
if ( $html !== false ) {
   echo $html;
} else {
   $this->widget_posts( $posts );
}

This way you're not echoing inside a filter which can be dangerous.

@sternb0t
Copy link
Author

Thanks, that definitely seems like a better way to do it. Updated.

@jonathanstegall
Copy link

This would still be really great to see in this plugin. I came here thinking of doing a PR for this but it's already here.

@GaryJones GaryJones added the type: enhancement New feature or request label Aug 8, 2024
@GaryJones GaryJones changed the base branch from main to develop August 8, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants